package org.lq.his.controller;

import java.util.List;

import javax.annotation.Resource;

import org.apache.ibatis.annotations.Param;
import org.lq.his.pojo.Address;
import org.lq.his.service.AddressService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/address")
public class AddressController {
	@Resource
	private AddressService addressService;

	public void setAddressService(AddressService addressService) {
		this.addressService = addressService;
	}
	@RequestMapping("/selectByTypeId")
	@ResponseBody
	public List<Address> selectByTypeId(@RequestParam(defaultValue="1")Integer typeId)throws Exception{
		
		return addressService.getByType(typeId);
		
	}
	@RequestMapping("/selectByParent")
	@ResponseBody
	public List<Address> selectByParent(Integer parentId)throws Exception{
		
		return addressService.getByParentId(parentId);
	}
	
	@RequestMapping("/selectAddressByTypeId")
	@ResponseBody
	public List<Address> selectAddressByTypeId(Integer typeId) throws Exception{
		
		return addressService.getAddressByTypeId(typeId);
	}
	
}
